package com.zs.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@ResponseBody
@RequestMapping("path")
public class PathController {
    /*
    * 路径传递参数和接收参数
    *    1. 设置动态路径{} 本层的路径是动态的 类似 * /* || /{key}
    *    2. 使用handle方法形参变量接受参数
    *       声明对应名称和对应类型变量 {type} String type
    *     必须使用@PathVariable注解接受路径参数 @PathVariable(name="", required = false)
    *     /path/type/id
    * */
    @GetMapping("{type}/do/{id}")
    public String path(@PathVariable(name="type") String erdaye,
                       @PathVariable(required = false) Integer id){
        System.out.println("type:"+erdaye+" id:"+id);
        return erdaye + id;
    }
}

